﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using EHTWebsiteProject.Code.Entity;
using System.Data.SqlClient;
using System.Data;
using EHTWebsite.Code;

namespace EHTWebsiteProject.Code.BLL
{
    public class FAQsProvider
    {
        public static void IUFAQs(FAQs theFAQs, bool IsAdd)
        {
            SqlCommand command = new SqlCommand();
            command.CommandText = "proc_IUFAQs";
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add(new SqlParameter("@ID", theFAQs.ID));
            command.Parameters.Add(new SqlParameter("@TitleFAQs", theFAQs.TitleFAQs));
            command.Parameters.Add(new SqlParameter("@ContentFAQs", theFAQs.ContentFAQs));
            command.Parameters.Add(new SqlParameter("@Status", theFAQs.Status));
            command.Parameters.Add(new SqlParameter("@Type", theFAQs.Type));
            command.Parameters.Add(new SqlParameter("@IsAdd", IsAdd));

            DataProvider.ExecuteNoneQuery(command);
        }
        public static void DeleteFAQs(Int32 ID)
        {
            SqlCommand command = new SqlCommand();
            command.CommandText = "proc_DeleteFAQsbyID";
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add(new SqlParameter("@ID", ID));

            DataProvider.ExecuteNoneQuery(command);
        }

        public static FAQs GetFAQsbyID(int ID)
        {
            SqlCommand command = new SqlCommand();
            command.CommandText = "proc_GetFAQSbyID";
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add(new SqlParameter("@ID", ID));

            DataSet ds = DataProvider.ExecuteDataSet(command);
            FAQs theFAQs = null;

            if (ds.Tables[0].Rows.Count > 0)
            {
                theFAQs = new FAQs();
                theFAQs.ID = Int32.Parse(ds.Tables[0].Rows[0]["ID"].ToString());
                theFAQs.TitleFAQs = ds.Tables[0].Rows[0]["TitleFAQs"].ToString();
                theFAQs.ContentFAQs = ds.Tables[0].Rows[0]["ContentFAQs"].ToString();
                theFAQs.Status = Boolean.Parse(ds.Tables[0].Rows[0]["Status"].ToString());
                theFAQs.Type = Int32.Parse(ds.Tables[0].Rows[0]["Type"].ToString());
            }

            return theFAQs;
        }

        public static DataSet GetFAQsByType(Int32 Type, Boolean IsSelectAll)
        {
            SqlCommand command = new SqlCommand();
            command.CommandText = "proc_GetFAQSbyType";
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.Add(new SqlParameter("@Type", Type));
            command.Parameters.Add(new SqlParameter("@IsSelectAll", IsSelectAll));
            return DataProvider.ExecuteDataSet(command);
        }
        public static DataSet GetFAQs()
        {
            SqlCommand command = new SqlCommand();
            command.CommandText = "proc_GetAllFAQs";
            command.CommandType = CommandType.StoredProcedure;

            return DataProvider.ExecuteDataSet(command);
        }
    }
}